package com.letv.whatslive.model.redis.chat.conf;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * Created by wangjian7 on 2016/5/19.
 */
public class UserChatRate {
    /**
     * 用户聊天行为最小间隔时间，单位：ms
     */
    private long minInterval = 1000L;

    /**
     * 用户聊天行为小于最小间隔时间，统计次数
     */
    private int maxCount = 10;

    /**
     * 用户聊天行为禁止时间，单位：ms
     */
    private Long forbidTime = 60*1000L;

    public UserChatRate(String json) {
        JSONObject jsonObject = JSON.parseObject(json);
        if(null!=jsonObject.getLong("minInterval")){
            this.minInterval = jsonObject.getLong("minInterval");
        }
        if(null!=jsonObject.getInteger("maxCount")){
            this.maxCount = jsonObject.getInteger("maxCount");
        }
        if(null!=jsonObject.getLong("forbidTime")){
            this.forbidTime = jsonObject.getLong("forbidTime");
        }
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public long getMinInterval() {
        return minInterval;
    }

    public int getMaxCount() {
        return maxCount;
    }

    public Long getForbidTime() {
        return forbidTime;
    }
}
